#include "common.h"

void init_general_timer4(void)
{
    RCC->APB1ENR |= (1 << 2);
    TIM4->CR1   = 0x80;
    TIM4->CCMR2 = 0x6000;
    TIM4->CCER |= (1 << 12);

    TIM4->PSC = 72 - 1;   // 输入时钟频率72M，分频后频率1M
    TIM4->ARR = 250 - 1;  // 250us一次

    TIM4->CCR4 = 125;
    TIM4->CR1 |= (1 << 0);
}
